package java_thinking.unit_18_IO._18_6;

import java.io.*;

/**
 * @Desc:   改造BasicFileOutput 使用LineNumberReader来记录行号
 * @author: cww
 * @DateTime: 2019/5/14 20:13
 */

public class E13_CountLines {
    static String file = "src/maindemo/java/java_thinking/unit_18_IO/_18_6/E13_CountLinesOut.txt";
    public static void main(String[] args) throws IOException {
        LineNumberReader in = new LineNumberReader(new FileReader("src/maindemo/java/java_thinking/unit_18_IO/_18_6/E13_CountLines.java"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file)));
        String s;
        while ((s = in.readLine()) != null) {
            out.println(in.getLineNumber() + ": " + s);
        }
        out.close();
        System.out.println(BufferedInputFile.read(file));
    }
}
